import json
import glob
import os

from modules import scripts

# 标签文件所在目录
PROMPT_DIR = os.path.join(scripts.basedir(), "prompt/prompt-data")

# 临时文件目录
TEMP_DIR = os.path.join(os.getcwd(), "tmp")


# 读取文件
def read_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        content = file.read()
    return content


def split_json():
    prompt = read_file(os.path.join(PROMPT_DIR, '../../prompt/prompt-data/prompt.json'))
    prompt_json = json.loads(prompt)
    for item in prompt_json:
        with open(os.path.join(PROMPT_DIR, item['name'] + '.json'), 'w', encoding='utf-8') as file:
            file.write(json.dumps(item, indent=2, ensure_ascii=False))
